<template>
	<view class="p-10">
		<view class="bg-white p-20 " style="padding-bottom: 50px">
			 
			<uni-table   border stripe @selection-change="selectionData">
				<uni-tr style=" position:sticky;top: 0;z-index: 999;">

					<uni-th v-for="(item,index) in th_list" align="center" >{{item.name}}</uni-th>

				 

				</uni-tr>
				<uni-tr v-for="(vo,index) in list" :key="index">
					
					
					<uni-td align="center"  v-for="(item,index) in th_list" >
						{{vo[item.field]}}
					</uni-td>
				 

				 
				</uni-tr>
			</uni-table>
			
<!-- 
			<edit ref="component_edit" @confirm="confirm_edit">
			</edit>
			<uni-popup ref="component_dels" type="center">
				<dels :id="id" @confirm="confirm_dels">
				</dels>
			</uni-popup> -->

		</view>
	</view>
</template>

<script>
	import edit from './edit.vue';
	import dels from './dels.vue';

	export default {
		components: {
			edit,
			dels,
		},
		data() {
			return {
				th_list:[],


				find: {},
				list: [],
				total: 0,
				page: 1,
				id: 0,
				is_top_height: false,
			}
		},
		onLoad(on) {

			this.init();
		},
		created() {
		 
		},
		methods: {
			//全选 反选
			selectionData(list) {
				console.log("list: " + JSON.stringify(list));
			},

			on_edit(index) {
				this.id = this.list[index]['id'];
				this.$refs.component_edit.init(this.id)
			},
			confirm_edit() {
				if (this.id == 0) {
					this.page = 1;
				}
				this.init();

			},
			on_dels(index) {
				this.id = this.list[index]['id'];
				this.$refs.component_dels.open()
			},
			confirm_dels() {
				this.init();
				this.$refs.component_dels.close()
			},


			getPage(id) {
				this.page = id.current;
				this.init()
			},
			on_add() {
				this.id = 0;
				this.$refs.component_edit.init(0)
			},
			on_search() {
				this.init();
			},
			on_search_resetting() {
				this.find = {};
				this.page = 1;
				this.init();
			},
			init() {
				var that = this;
				this.find['page'] = this.page
				this.Http.post('luyouzujiditu/admin/Adcategory/lists', this.find).then(ret => {
					// var list = ret.data.list.list.data;
					// this.list = list;
					// this.total = ret.data.list.list.total;
					
					this.th_list = ret.data.th_list
					this.list = ret.data.list
					
				})
			},
		}
	}
</script>

<style>
	.operate_button {
		width: 70px;
	}

	.operate_right {
		position: sticky;
		right: 0;
		z-index: 100;
		background-color: #fff;
	}
</style>